<template>
	<view style="background-color: #FFFFFF;">
		<view style="background-color: #FFFFFF;height: calc( 100vh - 280rpx); overflow-y: auto;padding-bottom: 40rpx;">
		<view class="tline" style="background-color: #F6FAFA;"></view>
		<view class="pl25 pr25">
			<view class="pt30 pb30 flex flex-ac flex-pj bb"  @click="toRecord">
				<text style="font-size: 30rpx;">咨询人</text>
				<view class="flex flex-ac" v-if="personalFileId==0">
					<text class="ft12" style="font-size: 30rpx;color: #B0B0B0;">请选择咨询人</text>
					<image class="arrow ml15" src="http://tuozhen1.oss-cn-beijing.aliyuncs.com/ueditor/upload/weixin/images/arrow.png"></image>
				</view>
				<view class="flex flex-ac" v-if="personalFileId!=0">
					<text class="ft12" style="font-size: 30rpx;">{{consultant}}</text>
					<image class="arrow ml15" src="http://tuozhen1.oss-cn-beijing.aliyuncs.com/ueditor/upload/weixin/images/arrow.png"></image>
				</view>
			</view>
			<view class="pt30 pb30 flex flex-ac flex-pj bb" @click="toAddress">
				<text style="font-size: 30rpx;">地址</text>
				<!-- <text class="it1 ftc ft12 c666">我们会根据您的位置为你匹配药房</text> -->
				<view class="flex flex-ac" v-if="adressInfo==0">
					<text class="it1 ftc ft12" style="font-size: 30rpx;color: #B0B0B0;">我们会根据您的位置为你匹配药房 </text>
					<text class="ft12" style="font-size: 30rpx;color: #B0B0B0;">请选择地址</text>
					<image class="arrow ml15" src="http://tuozhen1.oss-cn-beijing.aliyuncs.com/ueditor/upload/weixin/images/arrow.png"></image>
				</view>
				<view class="flex flex-ac" v-if="adressInfo!=0">
					<text class="ft12" style="font-size: 30rpx;">{{adressInfo}}</text>
					<image class="arrow ml15" src="http://tuozhen1.oss-cn-beijing.aliyuncs.com/ueditor/upload/weixin/images/arrow.png"></image>
				</view>
			</view>
			<view class="pt30 pb30 flex flex-ac flex-pj bb" @click="openaim">
				<text style="font-size: 30rpx;">问诊目的</text>
				<view class="flex flex-ac">
					<text v-if="aimkey==1" style="font-size: 30rpx;">在线复诊</text>
					<text v-else-if="aimkey==2" style="font-size: 30rpx;">复诊续方</text>
					<text v-else class="ft12" style="font-size: 30rpx;color: #B0B0B0;">请输入您的问诊目的</text>
					<image class="arrow ml15" src="http://tuozhen1.oss-cn-beijing.aliyuncs.com/ueditor/upload/weixin/images/arrow.png"></image>
				</view>
			</view>
			<view class="pt30 pb30 flex flex-ac flex-pj bb" v-if="aimkey==1" @click="toMedcalRecords">
				<text style="font-size: 30rpx;">就诊记录</text>
				<view class="flex flex-ac" v-if="consultant!=null&medcalRecords==0">
					<text class="ft12" style="font-size: 30rpx;color: #B0B0B0;">请选择需要复诊的就诊记录</text>
					<image class="arrow ml15" src="http://tuozhen1.oss-cn-beijing.aliyuncs.com/ueditor/upload/weixin/images/arrow.png"></image>
				</view>
				<view class="flex flex-ac" v-if="consultant!=null&medcalRecords!=0">
					<text class="ft12" style="font-size: 30rpx;">已选择就诊档案</text>
					<image class="arrow ml15" src="http://tuozhen1.oss-cn-beijing.aliyuncs.com/ueditor/upload/weixin/images/arrow.png"></image>
				</view>
			</view>
			
			
			<view class="pt30 pb30 flex flex-ac flex-pj bb" v-if="aimkey==1">
				<text style="font-size: 30rpx;">首诊医院</text>
				<view class="flex flex-ac">
					<input class="uni-input" v-model="hspName" placeholder="首诊医院名称" />
				</view>
			</view>
			
			
			<view class="pt30 pb30 flex flex-ac flex-pj bb" v-if="aimkey==2" @click="toChufangRecords">
				<text style="font-size: 30rpx;">历史处方</text>
				<view class="flex flex-ac" v-if="chufangRecords==0">
					<text class="ft12" style="font-size: 30rpx;color: #B0B0B0;">请选择需要复诊的历史处方</text>
					<image class="arrow ml15" src="http://tuozhen1.oss-cn-beijing.aliyuncs.com/ueditor/upload/weixin/images/arrow.png"></image>
				</view>
				<view class="flex flex-ac" v-if="chufangRecords!=0">
					<text class="ft12" style="font-size: 30rpx;">已选择历史处方</text>
					<image class="arrow ml15" src="http://tuozhen1.oss-cn-beijing.aliyuncs.com/ueditor/upload/weixin/images/arrow.png"></image>
				</view>
			</view>
			<view class="pt30 pb30 flex flex-ac flex-pj" @click="openwin">
				<text style="font-size: 30rpx;">预约时间</text>
				<view class="flex flex-ac">
					<text class="ft12" style="font-size: 30rpx;color: #B0B0B0;" v-if="!value">请选择问诊时间</text>
					<text v-else style="font-size: 30rpx;">{{value_all}}</text>
					<image class="arrow ml15" src="http://tuozhen1.oss-cn-beijing.aliyuncs.com/ueditor/upload/weixin/images/arrow.png"></image>
				</view>
			</view>
		</view>
		<view class="tline" style="background-color: #F6FAFA;"></view>
		<view class="pl25 pr25">
			<view class="pt30 pb30">症状描述</view>
			<!-- <textarea @input="setKeyword" v-if="keyword==0" class="block w100 pad20 box" maxlength="150" placeholder="请输入症状描述(150字)"></textarea> -->
			<textarea @input="setKeyword" class="block w100 pad20 box" maxlength="150"></textarea>
			<view class="pt30 pb30">患处照片<text class="ft12 c999" style="margin-left: 10rpx;">根据病情需要上传，系统加密仅医生可见</text></view>
			<view class="imgs pl10 pr10" style="align-items: center;flex-wrap: wrap;">
				<block v-for="(item,index) in Imgs" :key="index">
					<view style="position: relative;">
						<image :src="item" style="height: 186rpx;width: 186rpx;" mode="scaleToFill"></image>
						<image src="../static/imgs/xx.png" 
						style="height: 42rpx;width: 42rpx;border-radius: 50%;
							position: absolute;top:-10rpx;right: -10rpx;" @click="delImg(item)"></image>	
					</view>
				</block>
				<view v-if="Imgs.length<8" @click="uploadImg" style="width: 190rpx;height: 186rpx;background: #EDF6F5;border-radius: 8rpx;display: flex;flex-direction: column;align-items: center;justify-content: center;">
					<image src="../../static/images/pzp.png" style="width: 50%;" mode="widthFix"></image>
					<view>拍照</view>
				</view>
			</view>
			<view class="pt30 pb30">历史诊疗信息<text class="ft12 c999" style="margin-left: 10rpx;">其他医院病历、检验检查单拍照上传</text></view>
			<view class="imgs pl10 pr10" style="align-items: center;flex-wrap: wrap;">
				<block v-for="(item,index) in znImgs" :key="index">
					<view style="position: relative;">
						<image :src="item" style="height: 186rpx;width: 186rpx;" mode="scaleToFill"></image>
						<image src="../static/imgs/xx.png" 
						style="height: 42rpx;width: 42rpx;border-radius: 50%;
							position: absolute;top:-10rpx;right: -10rpx;" @click="delZnImg(item)"></image>	
					</view>
				</block>
				<view v-if="znImgs.length<8" @click="uploadZnImgs" style="width: 190rpx;height: 186rpx;background: #EDF6F5;border-radius: 8rpx;display: flex;flex-direction: column;align-items: center;justify-content: center;">
					<image src="../../static/images/pzp.png" style="width: 50%;" mode="widthFix"></image>
					<view>拍照</view>
				</view>
			</view>
			<view class="pt30 pb30">服务说明</view>
			<view class="c999 ft11">
				<view class="pt10 pb10">1.视频咨询按次收取费用，未接通不扣费</view>
				<view class="pt10 pb10">2.视频咨询时间最长为10分钟，超时后医生有权断开服务</view>
				<view class="pt10 pb10">3.视频咨询前请确保本应用已经开启了手机摄像头和麦克风权限</view>
				<view class="pt10 pb10">4.为保证您的权益和医生服务，咨询前请准备好您的病历或问题</view>
				<view class="pt10 pb10">5.视频预约前一小时不能退订，且一年只能退订3次请注意操作规范</view>
				<view class="pt10 pb10">6.在咨询中遇到任何问题导致无法正常完成咨询，您可以<!-- <text class="c74a6fd"> -->联系客服<!-- </text> -->留言或直接拨打<!-- <text class="c74a6fd"> -->65312135<!-- </text> -->反馈问题</view>
				<view class="pt10 pb10">7.订单结束后您可以对医生服务进行评价，您的建议是我们改进的动力，我们将持续优化我们的服务</view>
			</view>
		</view>
		</view>
		<view style="width: 100%;position: fixed;bottom: 40rpx;">
			<view class="add-btn" @click="insertVideoOrder">向医生问诊</view>
			<view class="pt20 pb20 flex flex-ac ft11" style="padding-left: 40rpx;margin-top: 20rpx;">
				<radio-group @click="state=!state">
				 	<radio value="1" :checked="state" color="#2A82E4"/>
				</radio-group>
				<text class="c999 ml15" style="margin-left: 0rpx;font-weight: bolder;">同意</text>
				<text class="c74a6fd ml5" @click="selectHopBook" style="color: #2A82E4;">邛崃民众门诊部患者知情同意书</text>
			</view>
		</view>
		
		<!-- <view class="bottomBtn ftc">
			<view class="bottomBtncon bgfff">
				<text class="cfff btns ct ftc block" @click="insertVideoOrder">向医生提问</text>
			</view>
		</view> -->

		<!-- 选择时间 -->
		<view class="win flex flex-ac flex-pc" v-if="winstate">
			<view class="ml25 mr25 w100 bgfff brund10" style="position: relative;">
				<view class="ft12 c999 pt30 pb30 ftc">请选择与医生预约的时间(左右滑动选择)</view>
				<image src="../static/imgs/xx.png"
				style="height: 70rpx;width: 70rpx;border-radius: 50%;
					position: absolute;top:-10rpx;right: -10rpx;" @click="winstate=false"></image>
				<view class="rela" style="height: 450rpx;overflow-y: auto;">
					<!-- <view class="abs arrowl bgfff" @click.stop="setDate" data-state="before">
						<image class=" arrow pl30 pr30" src="http://tuozhen1.oss-cn-beijing.aliyuncs.com/ueditor/upload/weixin/images/arrowl.png"></image>
					</view>
					<view class="abs arrowr bgfff" @click.stop="setDate" data-state="after">
						<image class=" arrow  pl30 pr30" src="http://tuozhen1.oss-cn-beijing.aliyuncs.com/ueditor/upload/weixin/images/arrowr.png"></image>
					</view> -->
					
					<swiper :current="current" style="height: 800rpx;">
						<block>
							<swiper-item>
								<view class="flex flex-ac flex-pc">
									<text class="ft16 bold date" :data-value="timerInfo">{{timerInfo}}</text>
								<!-- 	<view class="abs arrowr bgfff">
										<image class=" arrow  pl30 pr30" src="http://tuozhen1.oss-cn-beijing.aliyuncs.com/ueditor/upload/weixin/images/arrowr.png"></image>
									</view> -->
								</view>
								<view class="pl25 pr25 time pt20 pb20 overflow ftc" style="display: flex;flex-wrap: wrap;justify-content: space-between;">
									<template v-if="newfridayList.length>0">
										<!-- <text v-for="(item,index) in newfridayList" :key="index" @click.stop="choseTime" :data-value="timerInfo+''+item">
											{{item}}
										</text> -->
										
										<view style="width: 300rpx;margin-bottom: 20rpx;" v-for="(item,index) in newfridayList" :key="index" @click.stop="choseTime" :data-value="timerInfo+''+item">
											<view class="time-btn">{{item}}({{getyh2(index,timerInfo)}})</view>
											<!-- <view>{{item}}</view> 
											<view>余号：{{getyh2(index,timerInfo)}}</view> --> 
										</view>
										
									</template>
									<template v-else>
										<view class="ft12 c999 pt30 pb30 ftc">当日无排班</view>
									</template>
								</view>
							</swiper-item>

							<swiper-item v-if="newTimeDay[0].length!=1&&newTimeDay[0][0]!=''">
								<view class="flex flex-ac flex-pc">
									<text class="ft16 bold date" :data-value="twoDayList[0]">{{twoDayList[0]}}</text>
									<!-- <view class="abs arrowr bgfff">
										<image class=" arrow  pl30 pr30" src="http://tuozhen1.oss-cn-beijing.aliyuncs.com/ueditor/upload/weixin/images/arrowr.png"></image>
									</view> -->
								</view>
								<view class="pl25 pr25 time pt20 pb20  ftc" style="display: flex;flex-wrap: wrap;justify-content: space-between;">
									<template v-if="doctorTime.length>1 && doctorTime[1].isScheduling">
										<view style="width: 300rpx;margin-bottom: 20rpx;" v-for="(itemOne,indexOne) in newTimeDay[0]" :key="indexOne" @click.stop="choseTime" :data-value="twoDayList[0]+''+itemOne">
											<view class="time-btn">{{itemOne}}({{getyh(indexOne,twoDayList[0])}})</view> 
											<!-- <view>{{itemOne}}</view> 
											<view>余号：{{getyh(indexOne,twoDayList[0])}}</view> -->
										</view>
									</template>
									<template v-else>
										<view class="ft12 c999 pt30 pb30 ftc">当日无排班</view>
									</template>
								</view>
							</swiper-item>

							<swiper-item v-if="newTimeDay[1].length!=1&&newTimeDay[1][0]!=''">
								<view class="flex flex-ac flex-pc">
									<text class="ft16 bold date" :data-value="twoDayList[1]">{{twoDayList[1]}}</text>
									<!-- <view class="abs arrowr bgfff">
										<image class=" arrow  pl30 pr30" src="http://tuozhen1.oss-cn-beijing.aliyuncs.com/ueditor/upload/weixin/images/arrowr.png"></image>
									</view> -->
								</view>
								<view class="pl25 pr25 time pt20 pb20 ftc" style="display: flex;flex-wrap: wrap;justify-content: space-between;">
									<template v-if="doctorTime.length>2 && doctorTime[2].isScheduling">
										<view style="width: 300rpx;margin-bottom: 20rpx;" v-for="(itemTwo,indexTwo) in newTimeDay[1]" :key="indexTwo" @click.stop="choseTime" :data-value="twoDayList[1]+''+itemTwo">
											<view class="time-btn">{{itemTwo}}({{getyh(indexTwo,twoDayList[1])}})</view> 
											<!-- <view>{{itemTwo}}</view>
											<view>余号：{{getyh(indexTwo,twoDayList[1])}}</view> -->
										</view>
									</template>
									<template v-else>
										<view class="ft12 c999 pt30 pb30 ftc">当日无排班</view>
									</template>
								</view>
							</swiper-item>

							<swiper-item v-if="newTimeDay[2].length!=1&&newTimeDay[2][0]!=''">
								<view class="flex flex-ac flex-pc">
									<text class="ft16 bold date" :data-value="twoDayList[2]">{{twoDayList[2]}}</text>
									<!-- <view class="abs arrowr bgfff">
										<image class=" arrow  pl30 pr30" src="http://tuozhen1.oss-cn-beijing.aliyuncs.com/ueditor/upload/weixin/images/arrowr.png"></image>
									</view> -->
								</view>
								<view class="pl25 pr25 time pt20 pb20 ftc" style="display: flex;flex-wrap: wrap;justify-content: space-between;">
									<template v-if="doctorTime.length>3 && doctorTime[3].isScheduling">
										<view style="width: 300rpx;margin-bottom: 20rpx;" v-for="(itemthree,indexthree) in newTimeDay[2]" :key="indexthree" @click.stop="choseTime" :data-value="twoDayList[2]+''+itemthree">
											<view class="time-btn">{{itemthree}}({{getyh(indexthree,twoDayList[2])}})</view>
											<!-- <view>{{itemthree}}</view>
											<view>余号：{{getyh(indexthree,twoDayList[2])}}</view> -->
										</view>
									</template>
									<template v-else>
										<view class="ft12 c999 pt30 pb30 ftc">当日无排班</view>
									</template>
								</view>
							</swiper-item>

							<swiper-item v-if="newTimeDay[3].length!=1&&newTimeDay[3][0]!=''">
								<view class="flex flex-ac flex-pc">
									<text class="ft16 bold date" :data-value="twoDayList[3]">{{twoDayList[3]}}</text>
									<!-- <view class="abs arrowr bgfff">
										<image class=" arrow  pl30 pr30" src="http://tuozhen1.oss-cn-beijing.aliyuncs.com/ueditor/upload/weixin/images/arrowr.png"></image>
									</view> -->
								</view>
								<view class="pl25 pr25 time pt20 pb20 ftc" style="display: flex;flex-wrap: wrap;justify-content: space-between;">
									<template v-if="doctorTime.length>4 && doctorTime[4].isScheduling">
										<view style="width: 300rpx;margin-bottom: 20rpx;" v-for="(itemfour,indexfour) in newTimeDay[3]" :key="indexfour" @click.stop="choseTime" :data-value="twoDayList[3]+''+itemfour">
											<view class="time-btn">{{itemfour}}({{getyh(indexfour,twoDayList[3])}})</view>
											<!-- <view>{{itemfour}}</view>
											<view>余号：{{getyh(indexfour,twoDayList[3])}}</view> --> 
										</view>
									</template>
									<template v-else>
										<view class="ft12 c999 pt30 pb30 ftc">当日无排班</view>
									</template>
								</view>
							</swiper-item>

							<swiper-item v-if="newTimeDay[4].length!=1&&newTimeDay[4][0]!=''">
								<view class="flex flex-ac flex-pc">
									<text class="ft16 bold date" :data-value="twoDayList[4]">{{twoDayList[4]}}</text>
									<!-- <view class="abs arrowr bgfff">
										<image class=" arrow  pl30 pr30" src="http://tuozhen1.oss-cn-beijing.aliyuncs.com/ueditor/upload/weixin/images/arrowr.png"></image>
									</view> -->
								</view>
								<view class="pl25 pr25 time pt20 pb20 ftc" style="display: flex;flex-wrap: wrap;justify-content: space-between;">
									<template v-if="doctorTime.length>5 && doctorTime[5].isScheduling">
										<view style="width: 300rpx;margin-bottom: 20rpx;" v-for="(itemfive,indexfive) in newTimeDay[4]" :key="indexfive" @click.stop="choseTime" :data-value="twoDayList[4]+''+itemfive">
											<view class="time-btn">{{itemfive}}({{getyh(indexfive,twoDayList[4])}})</view>
											<!-- <view>{{itemfive}}</view>
											<view>余号：{{getyh(indexfive,twoDayList[4])}}</view> --> 
										</view>
									</template>
									<template v-else>
										<view class="ft12 c999 pt30 pb30 ftc">当日无排班</view>
									</template>
								</view>
							</swiper-item>

							<swiper-item v-if="newTimeDay[5].length!=1&&newTimeDay[5][0]!=''">
								<view class="flex flex-ac flex-pc">
									<text class="ft16 bold date" :data-value="twoDayList[5]">{{twoDayList[5]}}</text>
									<!-- <view class="abs arrowr bgfff">
										<image class=" arrow  pl30 pr30" src="http://tuozhen1.oss-cn-beijing.aliyuncs.com/ueditor/upload/weixin/images/arrowr.png"></image>
									</view> -->
								</view>
								<view class="pl25 pr25 time pt20 pb20 ftc" style="display: flex;flex-wrap: wrap;justify-content: space-between;">
									<template v-if="doctorTime.length>6 && doctorTime[6].isScheduling">
										<view style="width: 300rpx;margin-bottom: 20rpx;" v-for="(itemsix,indexsix) in newTimeDay[5]" :key="indexsix" @click.stop="choseTime" :data-value="twoDayList[5]+''+itemsix">
											<view class="time-btn">{{itemsix}}({{getyh(indexsix,twoDayList[5])}})</view>
											<!-- <view>{{itemsix}}</view>
											<view>余号：{{getyh(indexsix,twoDayList[5])}}</view> -->
										</view>
									</template>
									<template v-else>
										<view class="ft12 c999 pt30 pb30 ftc">当日无排班</view>
									</template>
								</view>
							</swiper-item>

							<swiper-item v-if="newTimeDay[6].length!=1&&newTimeDay[6][0]!=''">
								<view class="flex flex-ac flex-pc">
									<!-- <view class="abs arrowl bgfff">
										<image class=" arrow pl30 pr30" src="http://tuozhen1.oss-cn-beijing.aliyuncs.com/ueditor/upload/weixin/images/arrowl.png"></image>
									</view> -->
									<text class="ft16 bold date" :data-value="twoDayList[6]">{{twoDayList[6]}}</text>
								</view>
								<view class="pl25 pr25 time pt20 pb20 ftc" style="display: flex;flex-wrap: wrap;justify-content: space-between;">
									<template v-if="doctorTime.length>7 && doctorTime[7].isScheduling">
										<view style="width: 300rpx;margin-bottom: 20rpx;" v-for="(itemseven,indexseven) in newTimeDay[6]" :key="indexseven" @click.stop="choseTime" :data-value="twoDayList[6]+''+itemseven">
											<view class="time-btn">{{itemseven}}({{getyh(indexseven,twoDayList[6])}})</view>
											<!-- <view>{{itemseven}}</view>
											<view>余号：{{getyh(indexseven,twoDayList[6])}}</view> -->
										</view>
									</template>
									<template v-else>
										<view class="ft12 c999 pt30 pb30 ftc">当日无排班</view>
									</template>
								</view>
							</swiper-item>

						</block>
					</swiper>
				</view>

			</view>
		</view>

		<!-- 选择问诊目的 -->
		<view class="win flex flex-ac flex-pc" v-if="aimstate">
			<view class="ml25 mr25 w100 bgfff brund10">
				<view class="ft16 pt30 pb30 ftc">请选择问诊目的</view>
				<view class="rela aim">
					<view class="pt30 pb30 bb flex flex-ac flex-pj" @click.stop="aimkey=1">
						<view class="it1">
							<view class="ft16 bold">在线复诊</view>
							<view class="ft12 c999 mt20">针对复诊患者病情情况给出诊疗建议（可开具处方）</view>
						</view>
						<!-- <image v-if="aimkey==1" class="ycheck ml25" src="http://tuozhen1.oss-cn-beijing.aliyuncs.com/ueditor/upload/weixin/images/check2y.png"></image>
						<view v-else class="ncheck box ml25"></view> -->
						<radio value="1" :checked="aimkey==1" style="transform:scale(0.8);color: #2A82E4;" color="#2A82E4"/>
					</view>
					<view class="pt30 pb30 bb flex flex-ac flex-pj" @click.stop="aimkey=2">
						<view class="it1">
							<view class="ft16 bold">复诊续方</view>
							<view class="ft12 c999 mt20">针对复诊患者线上复诊以及再次复购药品</view>
						</view>
						<!-- <image v-if="aimkey==2" class="ycheck ml25" src="http://tuozhen1.oss-cn-beijing.aliyuncs.com/ueditor/upload/weixin/images/check2y.png"></image>
						<view v-else class="ncheck box ml25"></view> -->
						<radio value="2" :checked="aimkey==2" style="transform:scale(0.8);color: #2A82E4;" color="#2A82E4"/>
					</view>
					<view class="flex btnaum pt15 pb15 ft16">
						<text class="it1 ftc" @click="cancelaim">取消</text>
						<text class="c999 line"></text>
						<text class="it1 ftc c74a6fd" @click="confirmaim" style="color: #2A82E4;">确定</text>
					</view>
				</view>
			</view>
		</view>
		<view v-if='isSaveing' style="position: fixed;height: 100%;
			width: 100%;background-color: rgba(8, 8, 7, 0.5);z-index: 999;top:0rpx;left: 0rpx;display: flex;align-items: center;justify-content: center;">
			<icon type="waiting" size="26"/>
			<text style="color: #FFFFFF;margin-left: 20rpx;font-size: 38rpx;">提交中...</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				hspName:'',
				isNum: 1, //1：视频
				usrUserId: null, //用户ID
				wx: "https://app.mzmzb.com",//https://app.mzmzb.com   http://localhost:6110
				state: false,
				current: 0,
				winstate: false,
				value: '',
				value_all: '',
				aimstate: false,
				aimkey: null,
				consultant: null, //咨询人姓名
				sex: null, //咨询人姓名
				age: null, //咨询人姓名
				personalFileId: 0, //档案ID
				medDocInfoId: null, //医生ID
				videofee: null, //视频咨询费用
				adressInfo: 0, //收货地址
				medcalRecords: null, //流水号
				chufangRecords: 0, //处方
				timeDay: null, //医生首页传递的预约时间非集合(时分)
				timer: null, //当前时间
				weeks: null, //当前是周几
				keyword: 0, //输入的症状描述
				hoursInfo: null, //当前年月日时分
				timeNumList: [], //医生的查询预约时间的时间戳集合
				newfridayList: [], //比较当前时间剩下的时间集合（只包括时分）
				twoDayList: [], //未来的7天日期集合
				timerInfo: null, //当前年月日 周几
				ItemsTime: null,
				booktimeStr: null,
				timeDayList: [], //缓存里面的当天预约时间
				newTimeDay: [],
				isSaveing: false, // 是否正在提交订单
				Imgs: [],
				znImgs: [],
				videoPeopleNum: 0,
				
				docUserId: 0,
				docPhoto: null,
				docname: null,
				
				docSettingTime: null,
				doctorTime: [],
				getthisid:null,
				GoDocId:null,
				orderlist:[],
			};
		},
		onLoad(option) {
			if(option.orderlist){
				this.orderlist=JSON.parse(decodeURIComponent(option.orderlist))
			}
			this.videoPeopleNum = option.videoPeopleNum
			this.getTime();
			var that = this;
			that.usrUserId = uni.getStorageSync('usrUserId')
			// that.medDocInfoId = uni.getStorageSync('medDocInfoId')
			
			this.docUserId = option.docUserId
			this.medDocInfoId = option.medDocInfoId
			this.docPhoto = option.docPhoto
			this.docname = option.docname
			
			that.videofee = uni.getStorageSync('videofee')
			// that.timeDay = option.timeDay;
			this.doctorTime = JSON.parse(option.doctorTime) 
			if (option.personalFileId == 'null' || option.personalFileId == 'undefined') {
				that.personalFileId = 0;
			} else {
				that.consultant = uni.getStorageSync("name");
				that.personalFileId = uni.getStorageSync("personalFileId");
			}
			if (option.adressInfo == 'null' || option.adressInfo == 'undefined' || option.adressInfo == null) {
				that.adressInfo = 0;
			} else {
				that.adressInfo = uni.getStorageSync("adressInfo");
			}
			if (option.medcalRecordId == undefined) {
				that.medcalRecords = 0;
			} else {
				that.medcalRecords = uni.getStorageSync("medcalRecordId");
			}
			// that.Imgs = uni.getStorageSync('imgs');
			that.aimkey = option.aimkey;
			
			
			let newD = new Date();
			let newfridayList = this.toTimes(newD);
			this.newfridayList = newfridayList.filter(item=>{
				let nowh = newD.getHours();
				let itemTimes = item.split('-')
				return nowh * 1 < (itemTimes[1]?.substring(0,itemTimes[1].indexOf(':'))) * 1
			})
			
			// this.twoDayList.push(twoDay);
			// this.newTimeDay.push(timesList)
			
			// this.newfridayList
			
			// uni.getStorage({
			// 	key: "timeDay",
			// 	success: function(e) {
			// 		that.timeDayList = e.data.split(',')
			// 		that.timeDayList.forEach(function(item, index) {
			// 			var oldTime = that.timer + ' ' + item;
			// 			var timeNum = that.timeProcessing(oldTime);
			// 			that.timeNumList.push(timeNum)
			// 		});
			// 		var newTimeNum = that.timeProcessing(that.hoursInfo);
			// 		that.timeNumList.forEach(function(items, indexs) {
			// 			if (items > newTimeNum) {
			// 				that.newfridayList.push(that.timeDayList[indexs])
			// 			}
			// 		});
			// 	}
			// })

			uni.getStorage({
				key: "time",
				success: function(e) {
					that.value = e.data;
				}
			})
			uni.getStorage({
				key: "keyInfo",
				success: function(e) {
					that.keyword = e.data;
				}
			})
			that.booktimeStr = uni.getStorageSync('booktimeStrTime');
			that.state = uni.getStorageSync('state')
			console.log("用户ID:" + that.usrUserId)
			console.log("医生ID:" + that.medDocInfoId)
			console.log("视频咨询费用:" + that.videofee)
			console.log("档案ID:" + that.personalFileId)
			console.log("咨询人姓名:" + that.consultant)
			console.log("收货地址:" + that.adressInfo)
			console.log("病历号:" + that.medcalRecords)
			console.log("诊疗选择:" + that.aimkey)
			uni.setStorageSync("isNum", that.isNum)
			uni.setStorageSync("adressInfo", that.adressInfo)
			uni.setStorageSync("medcalRecords", that.medcalRecords)
			uni.setStorageSync("aimkey", that.aimkey)
			
			this.getDocSettingTime()
			
			this.getUserPersonalId()
		},

		onShow() {
			//查询订单状态
			setTimeout(() => {
				this.checkState()
			}, 100)
		},
		methods: {
			getUserPersonalId(){
				this.func.$request('wx/getUserPersonalId.tz',{userId: this.usrUserId,
						type:1},'GET','application/json').then(res=>{
							this.personalFileId = res.data.result.id
							this.consultant = res.data.result.name
							this.sex = res.data.result.sex
							const integerPart = Math.floor(res.data.result.age / 12);
							const remainder = res.data.result.age % 12;
							this.age=integerPart+'岁'+remainder+'个月'
						})
			},
			getyh2(idx,week){
				let nums = null
				if(week.indexOf('周日')>-1){
					nums = this.docSettingTime.sundayNum
				}
				if(week.indexOf('周一')>-1){
					nums = this.docSettingTime.mondayNum
				}
				if(week.indexOf('周二')>-1){
					nums = this.docSettingTime.tuesdayNum
				}
				if(week.indexOf('周三')>-1){
					nums = this.docSettingTime.wednesdayNum
				}
				if(week.indexOf('周四')>-1){
					nums = this.docSettingTime.thursdayNum
				}
				if(week.indexOf('周五')>-1){
					nums = this.docSettingTime.fridayNum
				}
				if(week.indexOf('周六')>-1){
					nums = this.docSettingTime.saturdayNum
				}
				let ll = this.newfridayList.length
				let numAyy = nums?.split(',');
				let ll2 = numAyy?.length - ll
				// nums = nums
				let all = this.videoPeopleNum*1
				let yum = nums?.split(',')[idx+ll2]
				
				
				return  (all-yum*1) || 0
			},
			getyh(idx,week){
				let nums = null
				if(week.indexOf('周日')>-1){
					nums = this.docSettingTime.sundayNum
				}
				if(week.indexOf('周一')>-1){
					nums = this.docSettingTime.mondayNum
				}
				if(week.indexOf('周二')>-1){
					nums = this.docSettingTime.tuesdayNum
				}
				if(week.indexOf('周三')>-1){
					nums = this.docSettingTime.wednesdayNum
				}
				if(week.indexOf('周四')>-1){
					nums = this.docSettingTime.thursdayNum
				}
				if(week.indexOf('周五')>-1){
					nums = this.docSettingTime.fridayNum
				}
				if(week.indexOf('周六')>-1){
					nums = this.docSettingTime.saturdayNum
				}
				let all = this.videoPeopleNum*1
				let yum = nums?.split(',')[idx]
				
				return  (all-yum*1) || 0
			},
			getDocSettingTime() {
				this.func.$request('getDocSettingTime.tz', {
					docId: this.medDocInfoId
				}, 'GET').then(res => {
					this.docSettingTime = res.data.result
				})
			},
			toChufangRecords() {
				if(this.consultant){
					uni.navigateTo({
						url: '/pages3/chufang/index?userId=' + this.usrUserId + '&medDocInfoId=' 
							+ this.medDocInfoId+'&usrPersonalId='+ this.personalFileId
							+'&isChinOrder=0'
					})
				}else{
					uni.showToast({
						title: '请选择咨询人',
						icon: 'error'
					})
				}
			},
			openwin() {
				this.winstate = !this.winstate;
			},
			setDate(e) {
				let state = e.currentTarget.dataset.state;
				if (state == 'before' && this.current > 0) {
					this.current = this.current - 1;
				} else if (state == 'after' && this.current < 2) {
					this.current = this.current + 1;
				}
			},
			choseTime(e) {
				var a = e.currentTarget.dataset.value;
				var b = a.substring(0, a.indexOf('周'));
				var c = a.substring(a.indexOf('周') + 2, a.length);
				console.log('choseTime===',a)
				this.value_all = a
				this.value = c;
				this.booktimeStr = b + c;
				uni.setStorage({
					key: 'time',
					data: this.value,
				})
				uni.setStorage({
					key: 'booktimeStrTime',
					data: this.booktimeStr,
				})
				this.openwin();
			},
			openaim() {
				this.aimstate = !this.aimstate;
			},
			confirmaim() {
				this.openaim();
			},
			cancelaim() {
				this.aimkey = null;
				this.openaim();
			},
			//跳转档案列表首页
			toRecord() {
				var that = this;
				uni.navigateTo({
					url: '/pages/record/index?userId=' + that.usrUserId + '&medDocInfoId=' + that.medDocInfoId + '&videofee=' + that
						.videofee + '&adressInfo=' + that.adressInfo + '&medcalRecords=' + that.medcalRecords + '&aimkey=' + that.aimkey +
						'&isNum=' + that.isNum
				})
			},
			//跳转到收货地址首页
			toAddress() {
				var that = this;
				uni.navigateTo({
					url: '/pages/address/index?userId=' + that.usrUserId + '&medDocInfoId=' + that.medDocInfoId + '&consultant=' +
						that.consultant + '&personalFileId=' + that.personalFileId + '&videofee=' + that.videofee + '&medcalRecords=' +
						that.medcalRecords + '&aimkey=' + that.aimkey + '&isNum=' + that.isNum
				})
			},
			toTitle() {
				uni.showToast({
					title: '请选择咨询人',
					icon: 'error'
				})
			},
			//跳转就诊记录首页
			toMedcalRecords() {
				var that = this;
				uni.navigateTo({
					url: '/pages2/jiuzjl/index?userId=' + that.usrUserId + '&medDocInfoId=' + that.medDocInfoId +
						'&consultant=' + that.consultant + '&personalFileId=' + that.personalFileId + '&videofee=' + that.videofee +
						'&adressInfo=' + that.adressInfo + '&aimkey=' + that.aimkey + '&isNum=' + that.isNum
				})
			},
			//获取当前时间和当前周几
			getTime() {
				var date = new Date();
				var year = date.getFullYear(); //当前年
				var month = date.getMonth() + 1; //当前月
				var day = date.getDate(); //当前日
				var week = date.getDay(); //当前一个周的第几天
				var hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
				var minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
				month >= 1 && month <= 9 ? (month = "0" + month) : "";
				day >= 0 && day <= 9 ? (day = "0" + day) : "";
				var timer = year + '-' + month + '-' + day; //当前年月日
				var hours = hour + ':' + minute //当前时分
				this.hoursInfo = timer + ' ' + hours //当前年月日时分
				this.timer = timer
				var weekInfo = week;
				if (weekInfo == 1) {
					this.weeks = '周一'
				}
				if (weekInfo == 2) {
					this.weeks = '周二'
				}
				if (weekInfo == 3) {
					this.weeks = '周三'
				}
				if (weekInfo == 4) {
					this.weeks = '周四'
				}
				if (weekInfo == 5) {
					this.weeks = '周五'
				}
				if (weekInfo == 6) {
					this.weeks = '周六'
				}
				if (weekInfo == 0) {
					this.weeks = '周日'
				}
				this.timerInfo = timer + ' ' + this.weeks
				let d = new Date(timer);
				for (var i = 0; i < 7; i++) {
					let newD = new Date(d.setDate(d.getDate() + 1)); //设置天数 +1 天
					var twoDay = this.toTime(newD);
					var timesList = this.toTimes(newD);
					this.twoDayList.push(twoDay);
					this.newTimeDay.push(timesList)
				}
				console.log('newTimeDay',this.newTimeDay)
			},
			//时间转换
			toTime(e) {
				var that = this
				var year = e.getFullYear(); //当前年
				var month = e.getMonth() + 1; //当前月
				var day = e.getDate(); //当前日
				var week = e.getDay(); //当前一个周的第几天
				month >= 1 && month <= 9 ? (month = "0" + month) : "";
				day >= 0 && day <= 9 ? (day = "0" + day) : "";
				var nowTimer = year + '-' + month + '-' + day; //当前年月日
				var weekInfo = week;
				var weekss = '';
				if (weekInfo == 1) {
					weekss = '周一';
				}
				if (weekInfo == 2) {
					weekss = '周二';
				}
				if (weekInfo == 3) {
					weekss = '周三';
				}
				if (weekInfo == 4) {
					weekss = '周四';
				}
				if (weekInfo == 5) {
					weekss = '周五';
				}
				if (weekInfo == 6) {
					weekss = '周六';
				}
				if (weekInfo == 0) {
					weekss = '周日';
				}
				var twoDay = nowTimer + ' ' + weekss;
				return twoDay
			},
			//返回周几的预约时间集合
			toTimes(e) {
				var that = this
				var year = e.getFullYear(); //当前年
				var month = e.getMonth() + 1; //当前月
				var day = e.getDate(); //当前日
				var week = e.getDay(); //当前一个周的第几天
				month >= 1 && month <= 9 ? (month = "0" + month) : "";
				day >= 0 && day <= 9 ? (day = "0" + day) : "";
				var nowTimer = year + '-' + month + '-' + day; //当前年月日
				var weekInfo = week;
				var timesList = [];
				if (weekInfo == 1) {
					var a = uni.getStorageSync('monday');
					if(a!=null){
						timesList = a.split(',')
					}
					return timesList
				}
				if (weekInfo == 2) {
					var a = uni.getStorageSync('tuesday');
					if(a!=null){
						timesList = a.split(',')
					}
					return timesList
				}
				if (weekInfo == 3) {
					var a = uni.getStorageSync('wednesday');
					if(a!=null){
						timesList = a.split(',')
					}
					return timesList
				}
				if (weekInfo == 4) {
					var a = uni.getStorageSync('thursday');
					if(a!=null){
						timesList = a.split(',')
					}
					return timesList
				}
				if (weekInfo == 5) {
					var a = uni.getStorageSync('friday');
					if(a!=null){
						timesList = a.split(',')
					}
					return timesList
				}
				if (weekInfo == 6) {
					var a = uni.getStorageSync('saturday');
					if(a!=null){
						timesList = a.split(',')
					}
					return timesList
				}
				if (weekInfo == 0) {
					var a = uni.getStorageSync('sunday');
					if(a!=null){
						timesList = a.split(',')
					}
					return timesList
				}
			},
			//获取症状描述输入的值
			setKeyword(e) {
				var that = this
				this.keyword = e.detail.value
				console.log(this.keyword)
				uni.setStorage({
					key: 'keyInfo',
					data: this.keyword,
				})
			},
			//转成时间戳
			timeProcessing(e) {
				let timeDate = e;
				let Time = new Date(timeDate);
				let timestemp = Time.getTime();
				return timestemp;
			},
			saveState() {
				var that = this
				that.state = !that.state;
				uni.setStorage({
					key: 'state',
					data: that.state
				})
			},
			getOrderId(orderId) {
				this.orderlist.forEach(e => {
					e.orderId = orderId
				})
				uni.request({
					url: `https://app.mzmzb.com/application-usrapp/zyf/saveZyfOrder.tz`,
					method: "GET",
					data: {
						dto: `{"orderList":` + JSON.stringify(this.orderlist) + `}`,
						userId: this.usrUserId
					},
					success(res) {
						console.log(res.data)
					}
				})
			},
			//提交
			insertVideoOrder() {
				if(this.isSaveing){
					return
				}
				this.isSaveing = true
				//关闭弹窗
				if(this.isSaveing == true){
					setTimeout(()=>{
						this.isSaveing = false
					},2500)
				}
				var that = this;
				let aimkey = null;
				if (that.state == true) {
					if (that.personalFileId > 0) {
						if (that.adressInfo == 'null' || that.adressInfo == 'undefined' || that.adressInfo == null || that.adressInfo ==
							0) {
							uni.showToast({
								title: '请选择地址',
								icon: 'error'
							})
							that.isSaveing = false
							return
						}
						if (that.aimkey == 'null' || that.aimkey == 'undefined' || that.aimkey == null) {
							uni.showToast({
								title: '请选择问诊目的',
								icon: 'error'
							})
							that.isSaveing = false
							return
						}

						if (that.keyword == 'null' || that.keyword == 'undefined' || that.keyword == null || that.keyword == 0) {
							uni.showToast({
								title: '请输入症状描述',
								icon: 'error'
							})
							that.isSaveing = false
							return
						}
						if (that.booktimeStr == 'null' || that.booktimeStr == 'undefined' || that.booktimeStr == null) {
							uni.showToast({
								title: '请选择预约时间',
								icon: 'error'
							})
							that.isSaveing = false
							return
						}
						
						
						if(that.aimkey==2 && (that.chufangRecords == 'null' 
							|| that.chufangRecords == 'undefined' || that.chufangRecords == null || that.chufangRecords == 0)){
							uni.showToast({
								title: '请选择历史处方',
								icon: 'error'
							})
							that.isSaveing = false
							return
						}
						
						
						
						if (that.medcalRecords == 'null' || that.medcalRecords == 'undefined' || that.medcalRecords == null || that.medcalRecords ==
							0) {
							that.medcalRecords = 0
						}
						
						if(that.aimkey==1 && that.medcalRecords==0 // 在线复诊
							&& that.znImgs.length==0){ 
							// uni.showToast({
							// 	title: '请上传历史诊疗信息',
							// 	icon: 'error'
							// })
							// that.isSaveing = false
							// return
						}
						console.log("medcalRecords:" + that.medcalRecords)
						console.log("price:" + that.videofee)
						console.log("medDocInfoId:" + that.medDocInfoId)
						console.log("usrPersonalFileId:" + that.personalFileId)
						console.log("address:" + that.adressInfo)
						console.log("problem:" + that.keyword)
						console.log("booktimeStr:" + that.booktimeStr)
						console.log("usrUserId:" + that.usrUserId)
						if(that.aimkey==1){
							aimkey = 0
						}
						if(that.aimkey==2){
							aimkey = 1
						}
						
						
						let imageArray = [].concat(that.Imgs).concat(that.znImgs)
						
						// console.log('imageArray: ====='+imageArray)
						// console.log("aimkey"+that.aimkey)
						if (that.medcalRecords == 0) {
							let url='userOrd/createVideoOrder.tz?usrUserId=' + that.usrUserId + '&price=' +
									that.videofee + '&medDocInfoId=' + that.medDocInfoId +
									'&usrPersonalFileId=' + that.personalFileId + '&address=' + that.adressInfo + '&problem=' + that
									.keyword + '&bookTimes=' + that.booktimeStr+'&isContinuation='+aimkey+'&image=' + imageArray +'&historyRecipeId='+that.chufangRecords+'&hspName='+that.hspName
							that.func.$request(url,{},'POST','application/x-www-form-urlencoded','WEIXIN').then(res=>{
								
									console.log(res.data);
									that.getthisid = res.data.result.id
									that.GoDocId = res.data.result.usrUserId
									if (res.data.success == true) {
										var price = res.data.result.price;
										var orderId = res.data.result.id;
										if (that.orderlist.length > 0) {
											that.getOrderId(orderId)
										}
										if(price==0){
											that.func.$request('pay/tzPay.tz?money=' + price + '&remark=' +
													orderId + '&usrGetTypeEnum=user_video_expenditure'+'&usrUserId='+that.usrUserId+'&thirdPayEnum=TzPay',{},'POST','application/x-www-form-urlencoded').then(item=>{
														if (item.data.success) {
															that.isSaveing = false
															that.sendMsg(orderId)
															that.joinChat(orderId)
														}
													})
											return
										}
										let parms = {
											id:res.data.result.id,
											medDocId:res.data.result.medDocInfoId,
											type:0
										}
										// 通联支付
										that.func.$request('wx/getWxPayParams.tz',parms,'GET').then(res=>{
											if(res.data.success){
												 uni.openEmbeddedMiniProgram({
													appId: 'wxef277996acc166c3',  
													extraData: {
														cusid: res.data.result.cusid,
														appid: res.data.result.appid, 
														orgid: res.data.result.orgid, 
														version: res.data.result.version, 
														trxamt: res.data.result.trxamt,
														reqsn: res.data.result.reqsn, 
														notify_url: res.data.result.notify_url, 
														body: res.data.result.body, 
														remark: res.data.result.remark, 
														validtime: res.data.result.validtime, 
														limit_pay: "", 
														randomstr: res.data.result.randomstr, 
														paytype: "W06", 
														sign:res.data.result.sign
													},
													//支付成功后跳转
													success(){
													
													}
												 })
											}
										}).catch(error=>{
											_this.isPaying = false
										})
									}
							})
							
						} else {
							that.medcalRecords = uni.getStorageSync("medcalRecordId")
							console.log("流水号3："+that.medcalRecords)
							let url='userOrd/createVideoOrder.tz?usrUserId=' + that.usrUserId + '&price=' +
									that.videofee + '&medDocInfoId=' + that.medDocInfoId +
									'&usrPersonalFileId=' + that.personalFileId + '&address=' + that.adressInfo + '&problem=' + that
									.keyword + '&bookTimes=' + that.booktimeStr+'&isContinuation='+aimkey+'&image=' + imageArray +'&historyRecipeId='+that.chufangRecords+'&hspName='+that.hspName
							that.func.$request(url,{},'POST','application/x-www-form-urlencoded','WEIXIN').then(res=>{
								
								
									that.getthisid = res.data.result.id
									that.GoDocId = res.data.result.usrUserId
									var price = res.data.result.price;
									// 通联参数
									let parms = {
										id:res.data.result.id,
										medDocId:res.data.result.medDocInfoId,
										type:0
									}
									if (res.data.success == true) {
										let orderId = res.data.result.id;
										if (that.orderlist.length > 0) {
											that.getOrderId(orderId)
										}
										if(price==0){
											that.func.$request('pay/tzPay.tz?money=' + price + '&remark=' +
													orderId + '&usrGetTypeEnum=user_video_expenditure'+'&usrUserId='+that.usrUserId+'&thirdPayEnum=TzPay',{},'POST','application/x-www-form-urlencoded').then(item=>{
														if (item.data.success) {
															that.isSaveing = false
															that.sendMsg(orderId)
															that.joinChat(orderId)
														}
													})
											return
										}
										
										// 通联支付
										
										// uni.login({
										// 	success: function(loginRes) {
										// 		that.func.$request('wx/messegPay.tz?money=' +
										// 				price + '&orderId=' +
										// 				orderId +
										// 				'&hspId=23840'
										// 				+ '&code=' + loginRes.code,{},'POST','application/x-www-form-urlencoded').then(item=>{
															
										// 						if (item.data.success) {
										// 							var timestamp = item.data
										// 								.result.timeStamp;
										// 							var nonceStr = item.data
										// 								.result.nonceStr;
										// 							var packages =
										// 								'prepay_id=' + item
										// 								.data.result.prepayid;
										// 							var paySign = item.data
										// 								.result.sign;
										// 							uni.requestPayment({
										// 								timeStamp: timestamp,
										// 								nonceStr: nonceStr,
										// 								package: packages,
										// 								signType: 'MD5',
										// 								paySign: paySign,
										// 								success: function(
										// 									res) {
										// 									that.sendMsg(
										// 										orderId
										// 									)
										// 									that.joinChat(
										// 										orderId
										// 									)
										// 								},
										// 								fail: function(
										// 									err) {
										// 									console
										// 										.log(
										// 											'fail:' +
										// 											JSON
										// 											.stringify(
										// 												err
										// 											)
										// 										);
										// 								}
										// 							});
										// 						} else {
										// 							that.isSaveing = false
										// 							that.isCreate = false
										// 							that.warnMessage = item
										// 								.data.errMsg;
										// 							that.warnTime = 3000;
										// 							that.$refs.popup.open();
										// 						}
										// 				}).catch(error=>{
										// 				that.isSaveing = false
										// 				that.warnMessage = '支付失败';
										// 				that.warnType = 'error';
										// 				that.$refs.popup.open();
										// 			})
										// 	}
										// });
										// that.func.$request('wx/getWxPayParams.tz',parms,'GET').then(res=>{
										// 	if(res.data.success){
										// 		 uni.openEmbeddedMiniProgram({
										// 			appId: 'wxef277996acc166c3',  
										// 			extraData: {
										// 				cusid: res.data.result.cusid,
										// 				appid: res.data.result.appid, 
										// 				orgid: res.data.result.orgid, 
										// 				version: res.data.result.version, 
										// 				trxamt: res.data.result.trxamt,
										// 				reqsn: res.data.result.reqsn, 
										// 				notify_url: res.data.result.notify_url, 
										// 				body: res.data.result.body, 
										// 				remark: res.data.result.remark, 
										// 				validtime: res.data.result.validtime, 
										// 				limit_pay: "", 
										// 				randomstr: res.data.result.randomstr, 
										// 				paytype: "W06", 
										// 				sign:res.data.result.sign
										// 			},
										// 			//支付成功后跳转
										// 			success(){
													
										// 			}
										// 		 })
										// 	}
										// }).catch(error=>{
										// 	_this.isPaying = false
										// })
													
									}
									
									uni.login({
										success: function(loginRes) {
											that.func.$request('wx/messegPay.tz?money=' +
													price + '&orderId=' +
													orderId +
													'&hspId=23840'
													+ '&code=' + loginRes.code,{},'POST','application/x-www-form-urlencoded').then(item=>{
														
															if (item.data.success) {
																var timestamp = item.data
																	.result.timeStamp;
																var nonceStr = item.data
																	.result.nonceStr;
																var packages =
																	'prepay_id=' + item
																	.data.result.prepayid;
																var paySign = item.data
																	.result.sign;
																uni.requestPayment({
																	timeStamp: timestamp,
																	nonceStr: nonceStr,
																	package: packages,
																	signType: 'MD5',
																	paySign: paySign,
																	success: function(
																		res) {
																		that.sendMsg(
																			orderId
																		)
																		that.joinChat(
																			orderId
																		)
																	},
																	fail: function(
																		err) {
																		console
																			.log(
																				'fail:' +
																				JSON
																				.stringify(
																					err
																				)
																			);
																	}
																});
															} else {
																that.isSaveing = false
																that.isCreate = false
																that.warnMessage = item
																	.data.errMsg;
																that.warnTime = 3000;
																that.$refs.popup.open();
															}
													}).catch(error=>{
													that.isSaveing = false
													that.warnMessage = '支付失败';
													that.warnType = 'error';
													that.$refs.popup.open();
												})
										}
									});
										
									
								
								})
						
						}
					} else {
						that.isSaveing = false
						uni.showToast({
							title: '请选择咨询人',
							icon: 'error'
						})
					}

				} else {
					that.isSaveing = false
					uni.showToast({
						title: '请仔细阅读邛崃民众门诊部患者知情同意书并勾选',
						icon: 'error'
					})
				}
			},
			
			//查询订单状态
			checkState() {
				var that = this
				// console.log(that.getthisid,'外');
				that.func.$request('wx/getOrderPayState.tz', {
					orderId: this.getthisid
				}, 'GET', 'application/x-www-form-urlencoded').then(res => {
					if (res.data.result == 1) {
						uni.showToast({
							title: '支付成功',
							icon: 'none',
							duration: 2000
						})
						//跳转聊天i
						that.sendMsg(that.getthisid)
						that.joinChat(that.getthisid, that.GoDocId)
						return
					} else if (res.data.result == 0) {
						console.log('未支付');
						// uni.showToast({title: '未支付', icon: 'none',duration: 2000})
						return
					} else {
						uni.showToast({
							title: '支付失败',
							icon: 'none',
							duration: 2000
						})
					}
				})
			},
			
			
			selectHopBook() {
				uni.navigateTo({
					url: '/pages/agreement/index'
				})
			},
			delImg(val){
				this.Imgs = this.Imgs.filter(item=>item!=val)
			},
			delZnImg(val){
				this.znImgs = this.znImgs.filter(item=>item!=val)
			},
			uploadZnImgs(){
				this.uploadImg("zn")
			},
			uploadImg(typeParam) {
				let imglx = '_hangchu'
				if(typeParam == 'zn'){
					imglx = '_zhenliao'
				}
				var that = this
				uni.chooseImage({
					count: 9, // 默认9
					sizeType: ['original', 'camera'], // 可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
					success: function(res) {
						uni.showLoading({
							title: '上传中...'
						});
						// 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片
						var tempFilePaths = res.tempFilePaths
						var myDate = new Date()
						var ossPath = 'ueditor/upload/weixin/' + myDate.getFullYear()
						var fileKeylist = []
						for (var i = 0; i < tempFilePaths.length; i++) {
							// 获取文件后缀
							//var pathArr = tempFilePaths[i].split('.')
							const imgsrc = res.tempFilePaths[i];
							const index = imgsrc.lastIndexOf(".");
							const imgExtension = imgsrc.substring(index + 1, imgsrc.length);
							console.log("后缀：" + imgExtension)
							//  随机生成文件名称
							var fileRandName = Date.now() + "" + parseInt(Math.random() * 1000)
							
							var fileName = fileRandName+imglx+ '.' + imgExtension
							// 要提交的key
							var fileKey = ossPath + '/' + fileName
							
							fileKeylist.push(fileKey)
							uni.uploadFile({
								url: 'https://tuozhen1.oss-cn-beijing.aliyuncs.com/',
								filePath: tempFilePaths[i],
								name: 'file',
								formData: {
									name: tempFilePaths[i],
									key: fileKey,
									policy: 'eyJleHBpcmF0aW9uIjoiMjMzNy0wNC0xM1QwMjo0MjoxMi40ODFaIiwiY29uZGl0aW9ucyI6W1siY29udGVudC1sZW5ndGgtcmFuZ2UiLDAsMTA0ODU3NjAwMF0sWyJzdGFydHMtd2l0aCIsIiRrZXkiLCJ1ZWRpdG9yL3VwbG9hZC93ZWl4aW4vIl1dfQ==',
									OSSAccessKeyId: 'Te5npXFe8IdIxPgQ',
									signature: 'I1Dv3FioQ4hoBh0ui2Rvsax+fAI=',
									success_action_status: "200"
								},
								success: function(res) {
									console.log(res)
								}
							})
						}
			
						setTimeout(function() {
							that.getImgs(fileKeylist,imglx);
						}, 5000);
					}
				})
			},
			getImgs(e,it) {
				var that = this;
				var Imgs = [...that.Imgs];
				var znImgs = [...that.znImgs];
				var imgLists = it=='_hangchu'?Imgs:znImgs;
				if (uni.getStorageSync('imgs').length != 0) {
					for (var j = 0; j < uni.getStorageSync('imgs').length; j++) {
						imgLists.push(uni.getStorageSync('imgs')[j])
					}
				}
				for (var i = 0; i < e.length; i++) {
					var upliadImages = "http://tuozhen1.oss-cn-beijing.aliyuncs.com/" + e[i];
					console.log("携带的参数：" + upliadImages)
					imgLists.push(upliadImages);
				}
				uni.hideLoading()
				if(it=='_hangchu'){
					that.Imgs = imgLists
				}else{
					that.znImgs = imgLists
				}
				
				// uni.setStorageSync('imgs', imgLists)
			},
			sendMsg(orderId){
				let avatarUrl = uni.getStorageSync("avatarUrl");
				let nickName = uni.getStorageSync("nickName");
				let from = uni.getStorageSync("usrUserId")
				let id = this.$im.conn.getUniqueId();
				let msg = new this.$im.message('txt', id);
				
				let extObj = {
					patientInfo: `${this.consultant} ${this.sex} ${this.age}`,
					problem:this.keyword,
					tcmQuestion:false,
					orderid:orderId,
					user_nickname:nickName,
					user_head:avatarUrl,
					user_id:from,
					messageType: 'txt',
					doctor_nickname: this.docname,
					doctor_id: this.medDocInfoId,
					doctor_head:this.docPhoto
				}
				
				let msgStr = ''
				if(this.aimkey == 2 ){
					msgStr = '[请求续方]'
					extObj.selectRecipeId = this.chufangRecords
				}else{
					msgStr = '[问诊单]'
				}
				if(this.Imgs && this.Imgs.length>0){
					extObj.images = this.Imgs.join(',')
				}
				msg.set({
					to: this.docUserId,
					from: from,
					msg: msgStr,
					roomType: false,
					chatType: 'singleChat',
					ext:extObj,
					success(){
						console.log('问诊通知成功了')
					},
					fail(){
						console.log('问诊通知失败了')
					}
				});
				this.$im.conn.send(msg.body);
			},
			//加入聊天
			joinChat(orderId) {
				let userId = uni.getStorageSync("usrUserId")
				let avatarUrl = uni.getStorageSync("avatarUrl");
				let nickName = uni.getStorageSync("nickName");
				var orderExt = {}; //发消息所需要的拓展数据
				orderExt.orderId = orderId;
				orderExt.messageType = '图文订单';
				orderExt.doctorId = this.docUserId;
				orderExt.doctorHead = this.docPhoto;
				orderExt.doctorNickname = this.docname;
				orderExt.userId = userId;
				orderExt.userHead = avatarUrl;
				orderExt.userNickname = nickName;
				orderExt.ordStatus = 1
				uni.redirectTo({
					url: '/pages/chatroom/chatroom?username=' + JSON.stringify(orderExt)
				});
			}
		}
	};
</script>

<style lang="less">
	.add-btn{
		margin: auto;
		height: 88rpx;
		line-height: 88rpx;
		width: 90%;
		background: linear-gradient(90deg, #F1BAB2 0%, #F78D7D 100%);
		box-shadow: 0px 20rpx 25rpx 0px rgba(247,141,125,0.4);
		border-radius: 44rpx;
		color: #FFFFFF;
		text-align: center;
	}
	.win {
		position: fixed;
		width: 100%;
		height: 100%;
		left: 0;
		top: 0;
		z-index: 100;
		background: rgba(0, 0, 0, 0.3);

		swiper {
			height: 450rpx;

			.arrow {
				width: 24rpx;
				height: 40rpx;
			}

			.date {
				line-height: 40rpx;
			}

			.arrowl {
				width: 10%;
				left: 0;
				padding-left: 15%;
				z-index: 100;
			}

			.arrowr {
				width: 10%;
				right: 0;
				padding-right: 15%;
				z-index: 100;
			}

			.time text {
				float: left;
				display: inline-block;
				width: 33.33%;
				line-height: 90rpx;
			}
		}

		.aim {
			padding: 0 50rpx;

			.ncheck {
				display: inline-block;
				width: 40rpx;
				height: 40rpx;
				border: 1rpx solid #EFEFEF;
			}

			.ycheck {
				width: 40rpx;
				height: 40rpx;
			}

			.btnaum {
				.line {
					width: 1rpx;
					background: #EFEFEF;
				}

				text {
					display: inline-block;
					height: 100rpx;
					line-height: 100rpx;
				}
			}
		}
	}

	textarea {
		height: 200rpx;
		border-radius: 5rpx;
		border: 1rpx solid #efefef;
	}

	.check2n {
		display: inline-block;
		width: 34rpx;
		height: 34rpx;
		border: 2rpx solid #838383;
	}

	.check2y {
		width: 24rpx;
		height: 24rpx;
	}

	.bottomBtn {
		margin-top: 30rpx;
		position: relative;
		height: 125rpx;
		width: 100%;

		.bottomBtncon {
			position: fixed;
			width: 700rpx;
			z-index: 10;
			left: 25rpx;
			height: 125rpx;
			bottom: 0;
			background: #FFFFFF;

			.btns {
				width: 660rpx;
				height: 100rpx;
				line-height: 100rpx;
				border-radius: 10rpx;
				background: #74a6fd;
			}
		}
	}
	
	.imgs {
		display: flex;
		image {
			width: 120rpx;
			height: 97rpx;
			margin: 10rpx;
		}
	}
	.time-btn {
		width: 280rpx;
		height: 88rpx;
		line-height: 88rpx;
		text-align: center;
		font-size: 32rpx;
		border: 1rpx solid #999;
		border-radius: 8rpx;
	}
</style>
